package com.capgemini.fs.app.ekms.service.implementations;

import java.util.List;

import com.capgemini.fs.app.ekms.model.Functionality;
import com.capgemini.fs.app.ekms.model.Role;
import com.capgemini.fs.app.ekms.persistence.PersistenceService;
import com.capgemini.fs.app.ekms.persistence.dao.RoleDAO;
import com.capgemini.fs.app.ekms.service.RoleService;

public class RoleServiceImpl implements RoleService {
	private PersistenceService	persistenceService	= null;

	public void createRole(Role role) {
		getRoleDAO().save(role);
	}

	public PersistenceService getPersistenceService() {
		return persistenceService;
	}

	public void setPersistenceService(PersistenceService persistenceService) {
		this.persistenceService = persistenceService;
	}

	public RoleDAO getRoleDAO() {
		return getPersistenceService().getRoleDAO();
	}

	public void addFunctionalityToRole(Role role, Functionality functionality) {
		getRoleDAO().addFunctionalityToRole(role, functionality);
	}

	public Role getRoleByName(String name) {
		return getRoleDAO().getRoleByName(name);
	}

	public List<Role> getAllRoles() {
		return getRoleDAO().findAll(Role.class);
	}

	public void updateRole(Role role) {
		getRoleDAO().update(role);
	}

	public Role getRoleById(Integer id) {
		return getRoleDAO().findByPrimaryKey(Role.class, id);
	}
}
